package com.frinder.official.akka.typed;

import akka.typed.ActorRef;
import akka.typed.Behavior;
import akka.typed.javadsl.Actor;

/**
 * Created by frinder on 2017/9/13.
 * <p>
 * 注：此模块暂不考虑！！！
 */
public abstract class HelloWorld {

    //no instances of this class, it's only a name space for messages
    // and static methods
    private HelloWorld() {
    }

    public static final class Greet {
        public final String whom;
        public final ActorRef<Greeted> replyTo;

        public Greet(String whom, ActorRef<Greeted> replyTo) {
            this.whom = whom;
            this.replyTo = replyTo;
        }
    }

    public static final class Greeted {
        public final String whom;

        public Greeted(String whom) {
            this.whom = whom;
        }
    }

    public static final Behavior<Greet> greeter = Actor.immutable((ctx, msg) -> {
        System.out.println("Hello " + msg.whom + "!");
        msg.replyTo.tell(new Greeted(msg.whom));
        return Actor.same();
    });

}
